import { ElMessage, ElMessageBox } from 'element-plus' // 错误类型枚举
import { h } from 'vue'

export const Message = (
  type: 'success' | 'error' | 'warning' | 'info',
  msg: string,
  instance?: any,
) => {
  ElMessage({
    type: type,
    message: `${msg} ${instance ? '来源 ' + instance : ''}`,
    plain: true,
    // duration: 0,
    icon: h(
      'span',
      { style: { fontStyle: 'normal' } },
      {
        default: () => {
          switch (type) {
            case 'success':
              return '✅'
            case 'error':
              return '❌'
            case 'warning':
              return '⚠️'
            case 'info':
              return 'ℹ️'
          }
        },
      },
    ),
  })
}
